
from rest_framework import serializers

from users.serializers import SpecializationTypeSerializer
from .models import Month, PredictionFact, Event, SpecDistribution


class PredictionFactSerializer(serializers.ModelSerializer):
    specialization = SpecializationTypeSerializer()
    class Meta:
        model = PredictionFact
        fields = '__all__'

class SpecDistributionSerializer(serializers.ModelSerializer):
    week = PredictionFactSerializer(read_only=True)
    class Meta:
        model = SpecDistribution
        fields = '__all__'

class MonthSerializer(serializers.ModelSerializer):
    weeks = PredictionFactSerializer(many=True, read_only=True)
    class Meta:
        model = Month
        fields = '__all__'

class MonthOnlySerializer(serializers.ModelSerializer):
    class Meta:
        model = Month
        fields = '__all__'


class EmptySerializer(serializers.Serializer):
    pass


class EventSerializer(serializers.ModelSerializer):
    date = serializers.SerializerMethodField(read_only=True)
    month = MonthOnlySerializer(read_only=True)
    class Meta:
        model = Event
        fields = '__all__'

    def get_date(self, obj):
        return obj.date
class EventPostSerializer(serializers.ModelSerializer):
    class Meta:
        model = Event
        fields = '__all__'


class ReportRequestSerializer(serializers.Serializer):
    year = serializers.IntegerField()
    month = serializers.IntegerField()
